package de.baumann.browser.present

import de.baumann.browser.api.OdinObserver
import de.baumann.browser.api.net.vo.PacketDetail
import de.baumann.browser.base.BasePresenter
import de.baumann.browser.iview.IPacketDetailView
import de.baumann.browser.model.PackModel

class PacketDetailPresenter : BasePresenter<IPacketDetailView>() {
    fun packetDetails() {
        PackModel().details(view.getPacketId())
                .subscribe(object : OdinObserver<PacketDetail>(view) {
                    override fun onSuccess(data: PacketDetail?) {
                        if (view != null && data != null) {
                            val packet = data.packet
                            view.setAmount(packet.packetAmount)
                            view.setHead(packet.avatar)
                            view.setLocal(packet.packetLocation)
                            view.setDesc(packet.description)
                            view.setName(packet.userName)
                            view.setRecord(data.list as ArrayList<PacketDetail.ListEntity>?)
//                            view.setBanners(packet.packetType, packet.img as ArrayList<PacketDetail.PacketEntity.ImgEntity>?)
                        }
                    }
                })
    }
}